//
//  AuditType.m
//  auditorias
//
//  Created by Mauro on 7/21/13.
//  Copyright (c) 2013 Antilope. All rights reserved.
//

#import "AuditType.h"
#import "DataLoader.h"

@implementation AuditType

@synthesize externalId;
@synthesize name;
@synthesize description;
@synthesize question;
@synthesize isQuestionAudit;
@synthesize requiresPhoto;
@synthesize tradeMKT;

- (void) dealloc
{
    [externalId release], externalId = nil;
    [name release], name = nil;
    [description release], description = nil;
    [question release], question = nil;
    [super dealloc];
}


- (id) initWithDictionary:(NSDictionary*)dictionary
{
    self = [super init];
    self.externalId = (![DataLoader isNull:[dictionary objectForKey:@"id"]]) ? [dictionary objectForKey:@"id"] : @"";
    self.name = (![DataLoader isNull:[dictionary objectForKey:@"name"]]) ? [dictionary objectForKey:@"name"] : @"";
    self.description = (![DataLoader isNull:[dictionary objectForKey:@"description"]]) ? [dictionary objectForKey:@"description"] : @"No hay descripción disponible";
    self.question = (![DataLoader isNull:[dictionary objectForKey:@"question"]]) ? [dictionary objectForKey:@"question"] : @"";
    self.isQuestionAudit = [self.question isEqualToString:@""]? false : true;
    self.requiresPhoto = (![DataLoader isNull:[dictionary objectForKey:@"requiresPhoto"]]) ? [[dictionary objectForKey:@"requiresPhoto"] boolValue] : true;
    self.tradeMKT = (![DataLoader isNull:[dictionary objectForKey:@"fromTradeMKT"]]) ? [[dictionary objectForKey:@"fromTradeMKT"] boolValue] : false;
    return self;
}

@end
